Prevent dragging groups into groups. Fixes #8706
[adiumx.git] / Plugins / General Preferences / ESGeneralPreferencesPlugin.m
blob9cee5fabbdbe3a43bff5f70a3d2a5ddac38b0de1
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 /* 
18  General Preferences. Currently responsible for:
19         - Logging enable/disable
20         - Message sending key (enter, return)
21         - Message tabs (create in tabs, organize tabs by group, sort tabs)
22         - Tab switching keys
23         - Sound:
24                 - Volume
25         - Status icon packs
27  In the past, these various items were with specific plugins.  While this provides a nice level of abstraction,
28  it also makes it much more difficult to ensure a consistent look/feel to the preferences.
31 #import <Adium/AIContentControllerProtocol.h>
32 #import <Adium/AIInterfaceControllerProtocol.h>
33 #import "ESGeneralPreferences.h"
34 #import "ESGeneralPreferencesPlugin.h"
35 #import <AIUtilities/AIDictionaryAdditions.h>
36 #import <AIUtilities/AISendingTextView.h>
37 #import <Adium/AIServiceIcons.h>
38 #import <Adium/AIStatusIcons.h>
40 #import "PTHotKey.h"
41 #import "PTHotKeyCenter.h"
43 #define TAB_DEFAULT_PREFS                       @"TabDefaults"
45 #define SENDING_KEY_DEFAULT_PREFS       @"SendingKeyDefaults"
47 #define CONFIRMATION_DEFAULT_PREFS      @"ConfirmationDefaults"
49 @interface ESGeneralPreferencesPlugin (PRIVATE)
50 - (void)_configureSendingKeysForObject:(id)inObject;
51 @end
53 @implementation ESGeneralPreferencesPlugin
55 - (void)installPlugin
57         //Defaults
58         [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:TAB_DEFAULT_PREFS
59                                                                                                                                                 forClass:[self class]]
60                                                                                   forGroup:PREF_GROUP_INTERFACE];
61         
62         [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:SENDING_KEY_DEFAULT_PREFS
63                                                                                                                                                 forClass:[self class]]
64                                                                                   forGroup:PREF_GROUP_GENERAL];
65         
66         [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:CONFIRMATION_DEFAULT_PREFS
67                                                                                                                                                 forClass:[self class]]
68                                           forGroup:PREF_GROUP_CONFIRMATIONS];
69         
70         //Install our preference view
71         preferences = [[ESGeneralPreferences preferencePaneForPlugin:self] retain];     
72         
73         [[adium preferenceController] registerPreferenceObserver:self forGroup:PREF_GROUP_GENERAL];
76 - (void)uninstallPlugin
81 - (void)hitHotKey:(PTHotKey *)hotKey
83         if (![NSApp isActive]) {
84                 [NSApp activateIgnoringOtherApps:YES];
85         }
87         //Switch to the appropriate window, just like clicking the dock; this method will handle switching to a chat with unviewed content, for example.
88         [[adium interfaceController] handleReopenWithVisibleWindows:NO];
89         
90         //Now ensure that all Adium windows are visible
91         [NSApp unhide:nil];
94 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key object:(AIListObject *)object
95                                         preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
97         if (firstTime || [key isEqualToString:KEY_GENERAL_HOTKEY]) {
98                 if (globalHotKey) {
99                         //Unregister the old global hot key if it exists
100                         [[PTHotKeyCenter sharedCenter] unregisterHotKey:globalHotKey];
101                         [globalHotKey release]; globalHotKey = nil;
102                 }
103                 
104                 id plistRepresentation = [prefDict objectForKey:KEY_GENERAL_HOTKEY];
105                 if (plistRepresentation) {
106                         //Register a new one if we want one
107                         globalHotKey = [[PTHotKey alloc] initWithIdentifier:KEY_GENERAL_HOTKEY
108                                                                                                            keyCombo:[[[PTKeyCombo alloc] initWithPlistRepresentation:plistRepresentation] autorelease]];
109                         
110                         [globalHotKey setTarget:self];
111                         [globalHotKey setAction:@selector(hitHotKey:)];
113                         [[PTHotKeyCenter sharedCenter] registerHotKey:globalHotKey];
114                 } 
115         }
118 @end